package com.luo.partner.service.impl;

import com.luo.common.annotation.BaseService;
import com.luo.common.base.BaseServiceImpl;
import com.luo.common.utils.Query;
import com.luo.partner.dao.mapper.TabRedMapper;
import com.luo.partner.dao.mapper.ext.ExtTabRedMapper;
import com.luo.partner.dao.model.TabRed;
import com.luo.partner.dao.model.TabRedExample;
import com.luo.partner.pojo.TabRedDO;
import com.luo.partner.service.TabRedService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * TabRedService实现
 * Created by laohu on 2018/9/6.
 */
@Service
@Transactional
@BaseService
public class TabRedServiceImpl extends BaseServiceImpl<TabRedMapper, TabRed, TabRedExample> implements TabRedService {

    private static final Logger LOGGER = LoggerFactory.getLogger(TabRedServiceImpl.class);

    @Autowired
    TabRedMapper tabRedMapper;

    @Autowired
    ExtTabRedMapper extTabRedMapper;

    @Override
    public TabRed get(Integer id) {
        
        return tabRedMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TabRedDO> list(Query query) {
        return extTabRedMapper.list(query);
    }

    @Override
    public int save(TabRed red) {
        return tabRedMapper.insert(red);
    }

    @Override
    public int update(TabRed red) {
        return tabRedMapper.updateByPrimaryKeySelective(red);
    }

    @Override
    public int remove(Integer id) {
        return tabRedMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<TabRed> list(Integer userId) {
        return null;
    }

    @Override
    public int batchRemove(Integer[] ids) {
        return 0;
    }

    @Override
    public int count(Query query) {
        return extTabRedMapper.count(query);
    }

    @Override
    public List<TabRed> findRedList(Long inviteUserId, BigDecimal un_settlement_recharge) {
    	TabRedExample example = new TabRedExample();
		TabRedExample.Criteria criteria = example.or();
		criteria.andUserIdEqualTo(inviteUserId);
		criteria.andStateEqualTo(1);
//		criteria.andLowerLimitLessThanOrEqualTo(un_settlement_recharge);
//		criteria.andUpLimitGreaterThanOrEqualTo(un_settlement_recharge);
		List<TabRed> list = tabRedMapper.selectByExample(example);
		return list;
    }
}